package com.cw.data;

import java.io.Serializable;

public class Result<T> implements Serializable {

    private Integer code;

    private String message;

    private T data;

    private static Result r = new Result();

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result() {
    }

    public static Result result(ConstantEnum ce) {

        r.setCode(ce.getCode());

        r.setMessage(ce.getMessage());

        return r;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public Result setData(T data) {
        this.data = data;
        return r;
    }
}
